
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>tkinter.font — Tkinter font wrapper &#8212; Python 3.9.6 documentation</title>
    <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python 3.9.6 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="next" title="Tkinter Dialogs" href="dialog.html" />
    <link rel="prev" title="tkinter.colorchooser — Color choosing dialog" href="tkinter.colorchooser.html" />
    <link rel="canonical" href="https://docs.python.org/3/library/tkinter.font.html" />
    
      
      
    

    
    <style>
      @media only screen {
        table.full-width-table {
            width: 100%;
        }
      }
    </style>

    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    
     


  </head><body>
  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="dialog.html" title="Tkinter Dialogs"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="tkinter.colorchooser.html" title="tkinter.colorchooser — Color choosing dialog"
             accesskey="P">previous</a> |</li>

    <li><img src="../_static/py.png" alt=""
             style="vertical-align: middle; margin-top: -1px"/></li>
    <li><a href="https://www.python.org/">Python</a> &#187;</li>
    

    <li>
      <a href="../index.html">3.9.6 Documentation</a> &#187;
    </li>

          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="tk.html" accesskey="U">Graphical User Interfaces with Tk</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" type="text" name="q" />
          <input type="submit" value="Go" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="module-tkinter.font">
<span id="tkinter-font-tkinter-font-wrapper"></span><h1><a class="reference internal" href="#module-tkinter.font" title="tkinter.font: Tkinter font-wrapping class (Tk)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.font</span></code></a> — Tkinter font wrapper<a class="headerlink" href="#module-tkinter.font" title="Permalink to this headline">¶</a></h1>
<p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.9/Lib/tkinter/font.py">Lib/tkinter/font.py</a></p>
<hr class="docutils" />
<p>The <a class="reference internal" href="#module-tkinter.font" title="tkinter.font: Tkinter font-wrapping class (Tk)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.font</span></code></a> module provides the <a class="reference internal" href="#tkinter.font.Font" title="tkinter.font.Font"><code class="xref py py-class docutils literal notranslate"><span class="pre">Font</span></code></a> class for creating
and using named fonts.</p>
<p>The different font weights and slants are:</p>
<dl class="data">
<dt id="tkinter.font.NORMAL">
<code class="sig-prename descclassname">tkinter.font.</code><code class="sig-name descname">NORMAL</code><a class="headerlink" href="#tkinter.font.NORMAL" title="Permalink to this definition">¶</a></dt>
<dt id="tkinter.font.BOLD">
<code class="sig-prename descclassname">tkinter.font.</code><code class="sig-name descname">BOLD</code><a class="headerlink" href="#tkinter.font.BOLD" title="Permalink to this definition">¶</a></dt>
<dt id="tkinter.font.ITALIC">
<code class="sig-prename descclassname">tkinter.font.</code><code class="sig-name descname">ITALIC</code><a class="headerlink" href="#tkinter.font.ITALIC" title="Permalink to this definition">¶</a></dt>
<dt id="tkinter.font.ROMAN">
<code class="sig-prename descclassname">tkinter.font.</code><code class="sig-name descname">ROMAN</code><a class="headerlink" href="#tkinter.font.ROMAN" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="class">
<dt id="tkinter.font.Font">
<em class="property">class </em><code class="sig-prename descclassname">tkinter.font.</code><code class="sig-name descname">Font</code><span class="sig-paren">(</span><em class="sig-param">root=None</em>, <em class="sig-param">font=None</em>, <em class="sig-param">name=None</em>, <em class="sig-param">exists=False</em>, <em class="sig-param">**options</em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.font.Font" title="Permalink to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="#tkinter.font.Font" title="tkinter.font.Font"><code class="xref py py-class docutils literal notranslate"><span class="pre">Font</span></code></a> class represents a named font. <em>Font</em> instances are given
unique names and can be specified by their family, size, and style
configuration. Named fonts are Tk’s method of creating and identifying
fonts as a single object, rather than specifying a font by its attributes
with each occurrence.</p>
<blockquote>
<div><p>arguments:</p>
<blockquote>
<div><div class="line-block">
<div class="line"><em>font</em> - font specifier tuple (family, size, options)</div>
<div class="line"><em>name</em> - unique font name</div>
<div class="line"><em>exists</em> - self points to existing named font if true</div>
</div>
</div></blockquote>
<p>additional keyword options (ignored if <em>font</em> is specified):</p>
<blockquote>
<div><div class="line-block">
<div class="line"><em>family</em> - font family i.e. Courier, Times</div>
<div class="line"><em>size</em> - font size</div>
<div class="line-block">
<div class="line">If <em>size</em> is positive it is interpreted as size in points.</div>
<div class="line">If <em>size</em> is a negative number its absolute value is treated</div>
<div class="line">as size in pixels.</div>
</div>
<div class="line"><em>weight</em> - font emphasis (NORMAL, BOLD)</div>
<div class="line"><em>slant</em> - ROMAN, ITALIC</div>
<div class="line"><em>underline</em> - font underlining (0 - none, 1 - underline)</div>
<div class="line"><em>overstrike</em> - font strikeout (0 - none, 1 - strikeout)</div>
</div>
</div></blockquote>
</div></blockquote>
<dl class="method">
<dt id="tkinter.font.Font.actual">
<code class="sig-name descname">actual</code><span class="sig-paren">(</span><em class="sig-param">option=None</em>, <em class="sig-param">displayof=None</em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.font.Font.actual" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the attributes of the font.</p>
</dd></dl>

<dl class="method">
<dt id="tkinter.font.Font.cget">
<code class="sig-name descname">cget</code><span class="sig-paren">(</span><em class="sig-param">option</em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.font.Font.cget" title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieve an attribute of the font.</p>
</dd></dl>

<dl class="method">
<dt id="tkinter.font.Font.config">
<code class="sig-name descname">config</code><span class="sig-paren">(</span><em class="sig-param">**options</em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.font.Font.config" title="Permalink to this definition">¶</a></dt>
<dd><p>Modify attributes of the font.</p>
</dd></dl>

<dl class="method">
<dt id="tkinter.font.Font.copy">
<code class="sig-name descname">copy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.font.Font.copy" title="Permalink to this definition">¶</a></dt>
<dd><p>Return new instance of the current font.</p>
</dd></dl>

<dl class="method">
<dt id="tkinter.font.Font.measure">
<code class="sig-name descname">measure</code><span class="sig-paren">(</span><em class="sig-param">text</em>, <em class="sig-param">displayof=None</em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.font.Font.measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Return amount of space the text would occupy on the specified display
when formatted in the current font. If no display is specified then the
main application window is assumed.</p>
</dd></dl>

<dl class="method">
<dt id="tkinter.font.Font.metrics">
<code class="sig-name descname">metrics</code><span class="sig-paren">(</span><em class="sig-param">*options</em>, <em class="sig-param">**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.font.Font.metrics" title="Permalink to this definition">¶</a></dt>
<dd><p>Return font-specific data.
Options include:</p>
<dl class="simple">
<dt><em>ascent</em> - distance between baseline and highest point that a</dt><dd><p>character of the font can occupy</p>
</dd>
<dt><em>descent</em> - distance between baseline and lowest point that a</dt><dd><p>character of the font can occupy</p>
</dd>
<dt><em>linespace</em> - minimum vertical separation necessary between any two</dt><dd><p>characters of the font that ensures no vertical overlap between lines.</p>
</dd>
</dl>
<p><em>fixed</em> - 1 if font is fixed-width else 0</p>
</dd></dl>

</dd></dl>

<dl class="function">
<dt id="tkinter.font.families">
<code class="sig-prename descclassname">tkinter.font.</code><code class="sig-name descname">families</code><span class="sig-paren">(</span><em class="sig-param">root=None</em>, <em class="sig-param">displayof=None</em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.font.families" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the different font families.</p>
</dd></dl>

<dl class="function">
<dt id="tkinter.font.names">
<code class="sig-prename descclassname">tkinter.font.</code><code class="sig-name descname">names</code><span class="sig-paren">(</span><em class="sig-param">root=None</em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.font.names" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the names of defined fonts.</p>
</dd></dl>

<dl class="function">
<dt id="tkinter.font.nametofont">
<code class="sig-prename descclassname">tkinter.font.</code><code class="sig-name descname">nametofont</code><span class="sig-paren">(</span><em class="sig-param">name</em><span class="sig-paren">)</span><a class="headerlink" href="#tkinter.font.nametofont" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a <a class="reference internal" href="#tkinter.font.Font" title="tkinter.font.Font"><code class="xref py py-class docutils literal notranslate"><span class="pre">Font</span></code></a> representation of a tk named font.</p>
</dd></dl>

</section>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="tkinter.colorchooser.html"
                        title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.colorchooser</span></code> — Color choosing dialog</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="dialog.html"
                        title="next chapter">Tkinter Dialogs</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">Report a Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/3.9/Doc/library/tkinter.font.rst"
            rel="nofollow">Show Source
        </a>
      </li>
    </ul>
  </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="dialog.html" title="Tkinter Dialogs"
             >next</a> |</li>
        <li class="right" >
          <a href="tkinter.colorchooser.html" title="tkinter.colorchooser — Color choosing dialog"
             >previous</a> |</li>

    <li><img src="../_static/py.png" alt=""
             style="vertical-align: middle; margin-top: -1px"/></li>
    <li><a href="https://www.python.org/">Python</a> &#187;</li>
    

    <li>
      <a href="../index.html">3.9.6 Documentation</a> &#187;
    </li>

          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="tk.html" >Graphical User Interfaces with Tk</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" type="text" name="q" />
          <input type="submit" value="Go" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 2001-2021, Python Software Foundation.
    <br />

    The Python Software Foundation is a non-profit corporation.
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br />
    <br />

    Last updated on Jun 28, 2021.
    <a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
    <br />

    Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 2.3.1.
    </div>

  </body>
</html>